package dao.impl;

import dao.BaseDao.BaseDao;
import javabean.Point;

import java.util.List;

public class PointDaoImpl extends BaseDao implements PointDao{
    @Override
    public int savePoint(Point point) {
        String sql = "insert into t_point(`pointExplain`,`needPoints`,`gainCouponId`,`pointPicture`) values(?,?,?,?)";
        return update(sql,point.getPointExplain(),point.getNeedPoints(),point.getGainCouponId(),point.getPointPicture());
    }

    @Override
    public int delectPointById(Integer id) {
        String sql = "delete from t_point where id = ?";
        return update(sql,id);
    }

    @Override
    public Point queryPointById(Integer id) {
        String sql="select `pointExplain`,`needPoints`,`gainCouponId`,`pointPicture` from t_point where id = ?";
        return queryForOne(Point.class,sql,id);
    }

    @Override
    public List<Point> queryPointList() {
        String sql="select `id`,`pointExplain`,`needPoints`,`gainCouponId`,`pointPicture` from t_point";
        return queryForList(Point.class,sql);
    }
}
